/**
 * 
 */
package de.dnb.basics.statistics;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import de.dnb.basics.applicationComponents.Pair;
import de.dnb.basics.applicationComponents.StringUtils;
import de.dnb.basics.filtering.IFunction;

/**
 * Implementation of Multimap that uses an LinkedList to store the values for a 
 * given key. A HashMap associates each key with an LinkedList of values.
 * 
 * This multimap allows duplicate key-value pairs. After adding a new 
 * key-value pair equal to an existing key-value pair, the ArrayListMultimap 
 * will contain entries for both the new value and the old value. 
 * Keys and values may be null. 
 * 
 * @author Christian_2
 *
 * @param <K>
 * @param <V>
 */
public class ListMultimap<K, V> extends Multimap<K, V> implements
	Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5034359466647088987L;

	public ListMultimap() {
		super(new HashMap<K, Collection<V>>());
	}

	

	@Override
	protected Collection<V> getNewValueCollection() {
		return new LinkedList<V>();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Multimap<String, String> multimap = new ListMultimap<>();
		multimap.add("1", "a");
		multimap.add("1", "b");
		multimap.add("1", "c");
		multimap.add("1", "a");
		multimap.add("2", "a");
		multimap.add("2", "b");
		multimap.add("3", "c");
		multimap.add("4");
		multimap.add("1");

		System.out.println(multimap);
		for (Iterator<String> iterator = multimap.valuesIterator(); iterator
				.hasNext();) {
				System.out.println(iterator.next());			
			}
	}

}
